package com.example.treasure_back.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.treasure_back.entity.MsgEntity;
import com.example.treasure_back.mapper.EssayMapper;
import com.example.treasure_back.model.EssayModel;
import com.example.treasure_back.model.GoodsModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/treasure/essay")
public class EssayController {

    @Autowired
    EssayMapper essayMapper;

    @RequestMapping("/getRefreshEssay")
    public MsgEntity getRefreshEssay(){
        QueryWrapper<EssayModel> objectQueryWrapper = new QueryWrapper<>();
        List<EssayModel> essayModels = essayMapper.selectList(objectQueryWrapper);
        return new MsgEntity("SUCCESS","200",essayModels);
    };

    @RequestMapping("/getEssayById/{id}")
    public MsgEntity getEssayById(@PathVariable Integer id){
        EssayModel essayModel = essayMapper.selectById(id);
        return new MsgEntity("SUCCESS","200",essayModel);
    }
}
